<?php

include("functions.php");

//Fetch requested page
$id = $_GET['id'];

if($id == login && $_POST['sent'] == 1) {
  $username = $_POST['username'];
  $password = $_POST['password'];
  $login_result = login($username, $password);
} else if($id == logout) {
  logout();
}

$privilege = authenticate();
echo $privilege;

?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

<html>
  <head>
    <title>Kampagne - </title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <meta name="description" content="">
    <meta name="Content-Language" content="de, li, ch">
    <meta name="language" content="de, li, ch">
    <meta name="author" content="Damian Frick">
    <meta name="ROBOTS" content="INDEX, FOLLOW">
    <meta name="revisit-after" content="2 days">
    <meta name="keywords" content="">

    <link href="style.css" rel="stylesheet" type="text/css">
    <link rel="shortcut icon" href="/images/favicon.ico" >
  </head>
  <body>
    <div id="header">
      <h1>Kampagne</h1>
    </div>
    <ul id="navigation">
      <li><a href="index.php">&Uuml;bersicht</a></li>
      <?php
        if($privilege == 0 || $privilege == 1) {
          echo "<li><a href='index.php?id=submitMove'>Zug eintragen</a></li>";
        }
        if($privilege == 0) {
          echo "<li><a href='index.php?id=admin'>Administration</a></li>";
        }
        if($privilege == 0 || $privilege == 1 || $privilege == 2) {
          echo "<li><a href='index.php?id=logout'>Logout</a></li>";
        }
        if($privilege == -1) {
          echo "<li><a href='index.php?id=login'>Login</a></li>
                <li><a href='index.php?id=register'>Registrieren</a></li>";
        }
      ?>
        
    </ul>
    <div id="content">
      <?php
        if($id == "submitMove") {
          include("submitMove.php");
        } else if($id == "login") {
          include("login.php");
        } else if($id == "register") {
          include("register.php");
        } else if($id == "logout") {
          include("logout.php");
        } else {
          include("overview.php");
        }
      ?>
    </div>
    <div id="footer"></div>
  </body>
</html>

